#ifndef SENSOR_CONNECTOR_H
#define SENSOR_CONNECTOR_H

#include <iostream>
#include <string>
#include <vector>
#include <memory>

#include "CSerialPort/SerialPort.h"
#include "sensor_config.h"
#include "serial_config.h"

namespace haptron {

typedef enum {
    NoneProtocol,
    Serial,
    Modbus,
} CommucationProtocol;

typedef struct ConnectorConfigStruct
{
    std::string port;
    SensorType sensor_type;
    CommucationProtocol com_pro;
} ConnectorConfig;

class SensorConnector
{
public:
    SensorConnector(const ConnectorConfig& config);
    ~SensorConnector();

    void set_serial_config(const SerialConfig& config);
    bool connect();
    void close();
    void get_raw_data(float& fx, float& fy, float& fz, float& mx, float& my, float& mz);
    void get_data(float& fx, float& fy, float& fz, float& mx, float& my, float& mz);

private:
    std::shared_ptr<itas109::CSerialPort> serial_port_;
    unsigned char serial_buff_[29];

    ConnectorConfig connector_config_;
    SerialConfig serial_config_;
    PhotonSerialFrameSetUp frame_setup_;

    std::vector<float> accumualte_wrench_;
    size_t accmulate_counter_;
};
}
#endif